﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmPostThread.aspx.cs" Inherits="WCrawler.frmPostThread" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>
<%@ Register Src="~/Controls/ucPost.ascx" TagName="ucPost" TagPrefix="UserControl" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="SearhThreadUpdatePaneL" runat="server">
        <ContentTemplate>
        <asp:PlaceHolder runat="server" ID="Body">
        <UserControl:ucPost id="ucPost" runat="server" OnGridViewPosts_SelectedIndexChanged="ucGridViewPosts_SelectedIndexChanged"/>
        </asp:PlaceHolder> 
    <div>
        <div>
            <asp:Label ID="Label6" runat="server" Text="Select group"></asp:Label>
            <asp:DropDownList ID="GroupDropDownList" runat="server" AutoPostBack="True" 
            DataSourceID="GroupLinqDataSource" DataTextField="GroupName" 
            DataValueField="GroupId" AppendDataBoundItems="True"
            onselectedindexchanged="GroupDropDownList_SelectedIndexChanged" 
            Height="20px" Width="89px">
            </asp:DropDownList>

            <asp:Label ID="Label7" runat="server" Text="Is Posted"></asp:Label>
            <asp:DropDownList ID="dropDownListStatus" runat="server" AutoPostBack="True"
                onselectedindexchanged="dropDownListStatus_SelectedIndexChanged" 
                Width="90px">
                <asp:ListItem Value="0" Selected="True">UnPosted</asp:ListItem>
                <asp:ListItem Value="1" >Posted</asp:ListItem>
                <asp:ListItem>All</asp:ListItem>
            </asp:DropDownList>
        </div>
        <div>
        <asp:Button ID="btnDoPost" runat="server" ForeColor="Red" onclick="btnDoPost_Click" 
            Text="Do Post" />
        <asp:Button ID="btnPostReply" runat="server" ForeColor="Red" 
            Text="Do Reply" onclick="btnPostReply_Click" />
        <asp:Button ID="btnPostUpdate" runat="server" ForeColor="Red" 
            Text="Edit &amp; Reply" onclick="btnPostUpdate_Click" />
        <asp:Button ID="btnEditWithoutReply" runat="server" ForeColor="Red" 
            Text="Edit Without Reply" onclick="btnEditWithoutReply_Click" />
            <asp:Button ID="btnUpdateInfo" runat="server" Text="Update Info" 
                onclick="btnUpdateInfo_Click" />
            <asp:Label ID="lblReport" runat="server" ForeColor="Red"></asp:Label>
            <asp:Button ID="btnDeleteThreads" runat="server" Text="Delete Threads" 
                onclick="btnDeleteThreads_Click" />
             
            <asp:Button ID="btnOpenNewThreadUrl" runat="server" 
                onclick="btnOpenNewThreadUrl_Click" Text="Open New Thread Url" OnClientClick="document.getElementById('form1').target ='_blank';" />
    </div>
    <div>

        <asp:Label ID="Label12" runat="server" Text="Show forums per page"></asp:Label>
        <asp:DropDownList ID="dropDownListNumberOfRows" runat="server" 
            AutoPostBack="True" 
            onselectedindexchanged="dropDownListNumberOfRows_SelectedIndexChanged">
            <asp:ListItem>10</asp:ListItem>
            <asp:ListItem>20</asp:ListItem>
            <asp:ListItem>50</asp:ListItem>
            <asp:ListItem>100</asp:ListItem>
            <asp:ListItem>All</asp:ListItem>
        </asp:DropDownList>

    </div>
    <div>
    <asp:Panel ID="panelForums" runat="server">
        <asp:GridView ID="gridViewForums" runat="server" 
        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ForumId" 
        DataSourceID="ForumLinqDataSource" BackColor="White" 
        BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
        GridLines="Vertical" Width="100%" 
        onrowdatabound="gridViewForums_RowDataBound">
        <AlternatingRowStyle BackColor="#DCDCDC" />
        <EmptyDataTemplate>
            <asp:Label ID="lblEmptySearch" runat="server" Font-Bold="True" ForeColor="#0033CC">No Results Found....  
            </asp:Label>
        </EmptyDataTemplate>
        <Columns>
            <asp:TemplateField HeaderText="Select" ItemStyle-HorizontalAlign="Center">
                <HeaderTemplate>
                <asp:CheckBox ID="chkHead" runat="server"
                onclick="changeCheckState(this);" />
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:CheckBox ID="chkCheckItem" Runat="server" />
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center"></ItemStyle>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="#" ItemStyle-HorizontalAlign="Center">
                <ItemTemplate>
                    <asp:Label ID="lblNum" Runat="server" />
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center"></ItemStyle>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Url" SortExpression="ForumUrl">
                <ItemTemplate>
                    <asp:HyperLink ID="Url" NavigateUrl='<%#Eval("ForumUrl")%>' runat="server" Text='<%#Eval("ForumUrl")%>' />
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtUrl" runat="server" Text='<%# Bind("ForumUrl") %>'></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Location" SortExpression="Location.LocationName">
                <ItemTemplate>
                    <asp:Image ID="imgFlag" ImageUrl='<%#Eval("Location.FlagUrl")%>'  runat="server" />
                    <asp:Label ID="lblLocationName" runat="server" Text='<%#Eval("Location.LocationName")%>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Rank" SortExpression="AlexaRank">
                <ItemTemplate>
                    <asp:Label ID="lblAlexaRank" runat="server" Text='<%#Eval("AlexaRank")%>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Type" SortExpression="ForumType.TypeName">
                <ItemTemplate>
                    <asp:Label ID="lblForumType" runat="server" Text='<%#Eval("ForumType.TypeName")%>'></asp:Label>
                    <asp:Label ID="lblVersion" runat="server" Text='<%#Bind("Version")%>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Topic" SortExpression="Topic">
                <ItemTemplate>
                    <asp:HyperLink ID="hyperLinkTopic" runat="server"> </asp:HyperLink>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Thread" SortExpression="Thread">
            <ItemTemplate>
                <asp:HyperLink ID="hyperLinkThread" runat="server"> </asp:HyperLink>
            </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Create" SortExpression="Create">
                <ItemTemplate>
                    <asp:Label ID="lblCreateOn" runat="server"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Update" SortExpression="Update">
                <ItemTemplate>
                    <asp:Label ID="lblUpdateOn" runat="server"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Notes" SortExpression="Notes">
                <ItemTemplate>
                    <asp:Label ID="lblNotes" runat="server" Text='<%#Eval("Notes")%>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
        <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
        <PagerSettings Mode="NumericFirstLast" />
        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
        <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
        <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle BackColor="#F1F1F1" />
        <SortedAscendingHeaderStyle BackColor="#0000A9" />
        <SortedDescendingCellStyle BackColor="#CAC9C9" />
        <SortedDescendingHeaderStyle BackColor="#000065" />
    </asp:GridView>
    </asp:Panel>
    <asp:Panel ID="panelForumThreads" runat="server">
        <asp:GridView ID="gridViewForumThreads" runat="server" AllowPaging="True" 
                    AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" 
                    DataKeyNames="ForumThreadId" DataSourceID="ForumThreadsLinqDataSource" 
                    ForeColor="#333333" onrowdatabound="gridViewForumThreads_RowDataBound" 
                    Width="100%">
                    <EditRowStyle BackColor="#2461BF" />
                    <EmptyDataTemplate>
                        <asp:Label ID="lblEmptySearch0" runat="server" Font-Bold="True" 
                            ForeColor="#0033CC">No Results Found....  
                </asp:Label>
                    </EmptyDataTemplate>
                    <AlternatingRowStyle BackColor="White" />
                    <Columns>
                        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                        <asp:TemplateField HeaderText="Select" ItemStyle-HorizontalAlign="Center">
                            <HeaderTemplate>
                            <asp:CheckBox ID="chkHead" runat="server"
                            onclick="changeCheckState(this);" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="chkCheckItem" Runat="server" />
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center"></ItemStyle>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="#" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label ID="lblNum" Runat="server" />
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center"></ItemStyle>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Url" SortExpression="ForumUrl">
                            <ItemTemplate>
                                <asp:HyperLink ID="Url" NavigateUrl='<%#Eval("Forum.ForumUrl")%>' runat="server" Text='<%#Eval("Forum.ForumUrl")%>' />
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtUrl" runat="server" Text='<%# Bind("Forum.ForumUrl") %>'></asp:TextBox>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Location" SortExpression="Location.LocationName">
                            <ItemTemplate>
                                <asp:Image ID="imgFlag" ImageUrl='<%#Eval("Forum.Location.FlagUrl")%>'  runat="server" />
                                <asp:Label ID="lblLocationName" runat="server" Text='<%#Eval("Forum.Location.LocationName")%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Rank" SortExpression="AlexaRank">
                            <ItemTemplate>
                                <asp:Label ID="lblAlexaRank" runat="server" Text='<%#Eval("Forum.AlexaRank")%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Type" SortExpression="ForumType.TypeName">
                            <ItemTemplate>
                                <asp:Label ID="lblForumType" runat="server" Text='<%#Eval("Forum.ForumType.TypeName")%>'></asp:Label>
                                <asp:Label ID="lblVersion" runat="server" Text='<%#Bind("Forum.Version")%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Topic" SortExpression="Topic">
                            <ItemTemplate>
                                <asp:HyperLink ID="hyperLinkTopic" runat="server"> </asp:HyperLink>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Thread" SortExpression="Thread">
                        <ItemTemplate>
                            <asp:HyperLink ID="hyperLinkThread" runat="server" NavigateUrl='<%# Eval("Forum.ForumUrl") + "/" + Eval("ThreadUrl")%>' Text='<%#Eval("ThreadNum")%>'> </asp:HyperLink>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtThreadNum" runat="server" Text='<%# Bind("ThreadNum") %>'></asp:TextBox>
                            <asp:TextBox ID="txtThreadUrl" runat="server" Text='<%# Bind("ThreadUrl") %>'></asp:TextBox>
                        </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Create" SortExpression="Create">
                            <ItemTemplate>
                                <asp:Label ID="lblCreateOn" runat="server" Text='<%#Eval("CreateOn")%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Update" SortExpression="Update">
                            <ItemTemplate>
                                <asp:Label ID="lblUpdateOn" runat="server" Text='<%#Eval("UpdateOn")%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Notes" SortExpression="Notes">
                            <ItemTemplate>
                                <asp:Label ID="lblNotes" runat="server" Text='<%#Eval("Forum.Notes")%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                    <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                    <PagerSettings Mode="NumericFirstLast" />
                    <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                    <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                    <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
                    <SortedAscendingCellStyle BackColor="#F1F1F1" />
                    <SortedAscendingHeaderStyle BackColor="#0000A9" />
                    <SortedDescendingCellStyle BackColor="#CAC9C9" />
                    <SortedDescendingHeaderStyle BackColor="#000065" />
                </asp:GridView>
    </asp:Panel>
    </div>
    </div>

    <div>
    <!-- Popup show full content-->
        <asp:Button ID="btnShowPopup" runat="server" style="display:none" />
        <ajaxToolkit:ModalPopupExtender id="mdlPopup" runat="server" 
            backgroundcssclass="BackgroundStyle" popupcontrolid="PanelReplyContent" 
            targetcontrolid="btnShowPopup">
        </ajaxToolkit:ModalPopupExtender>
        <asp:Panel ID="PanelReplyContent" runat="server" BackColor="#ffffff" 
            BorderColor="#dadada" BorderStyle="Solid" BorderWidth="4px" Font-Names="Arial" 
            Font-Size="10pt" Width="800px">
            <table cellpadding="10" cellspacing="0" style="width: 100%">
                <tr>
                    <td>
                        <asp:TextBox ID="txtReplyContent" runat="server" Rows="10" TextMode="MultiLine" 
                            Width="100%"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td align="center" valign="middle">
                        <asp:Button ID="btnSend" runat="server" Text="Send" onclick="btnSend_Click" />
                        <asp:Button ID="btnCancel" runat="server" Text="Cancel" />
                        <br />
                        <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
                    </td>
                </tr>
            </table>
        </asp:Panel>
    </div>
    </ContentTemplate>
    </asp:UpdatePanel>
<asp:LinqDataSource ID="ForumLinqDataSource" runat="server" 
        ContextTypeName="WCrawlerLib.LinqDataClassesDataContext" EntityTypeName="" 
        TableName="Forums" EnableDelete="True" EnableInsert="True" 
        onselecting="ForumLinqDataSource_Selecting" EnableUpdate="True">
    </asp:LinqDataSource>
        <asp:LinqDataSource ID="GroupLinqDataSource" runat="server" 
            ContextTypeName="WCrawlerLib.LinqDataClassesDataContext" EntityTypeName="" 
            TableName="ForumGroups">
        </asp:LinqDataSource>
    <asp:LinqDataSource ID="ForumThreadsLinqDataSource" runat="server" 
        ContextTypeName="WCrawlerLib.LinqDataClassesDataContext" EntityTypeName="" 
        onselecting="ForumThreadsLinqDataSource_Selecting" 
        TableName="ForumThreads" EnableDelete="True" EnableUpdate="True">
    </asp:LinqDataSource>
        <br />
    
        </asp:Content>
